<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>小儿推拿</title>
    <%@ include file="/include/datetables.jsp"%>
</head>
<body>
<div class="Baby_Healthy_home">
    <!--左侧-->
    <jsp:include page="/include/menu.jsp" flush="true">
        <jsp:param name="index" value="8"/>
    </jsp:include>
    <!--右侧-->
    <div class="Baby_Healthy_home_right">
        <div class="Baby_Healthy_home_right_top">
            <ul class="Baby_Healthy_home_right_top_list card_bgc">
                <li class="num1  bespeak_active">员工管理</li>
            </ul>
        </div>
        <!--卡-->
        <div class="Baby_Healthy_home_right_bespeak_list">
            <div class="Baby_Healthy_home_right_bespeak_search card_bgc_fff">
                <div class="staffManagement_btn">
                    <a class="btn btn-info btn-sm js_power_34" href="${pageContext.request.contextPath}/sysuser/gotoAddSysUser" style="height: 28px">添加员工</a>
                    <a class="btn btn-info btn-sm js_power_35" href="${pageContext.request.contextPath}/sysuser/gotoCtaffManagement_q" style="height: 28px">已离职员工</a>
                    <a class="btn btn-info btn-sm js_power_36" href="${pageContext.request.contextPath}/sysuser/gotoSysUserAchievements" style="height: 28px">员工绩效</a>
                </div>
                <div class="Baby_Healthy_home_right_bespeak_btn_searchbox">
                    <select class="form-control bespeak_search_input js_power_45" name="" id="store">
                        <option value="-1">全部门店</option>
                    </select>
                    <button id = "bespeak_search_button" class="bespeak_search_button">搜索</button>
                </div>
            </div>
            <!--员工管理-->
            <div class="zccard_container">
                <table class="zctable table table-striped table-no-bordered table-hover js_user_list">
                    <thead>
                    <tr>
                        <th class="">系统账号</th>
                        <th class="">所属门店</th>
                        <th class="">角色</th>
                        <th class="">联系方式</th>
                        <th class="">添加时间</th>
                        <th class="">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${pageContext.request.contextPath}/js/zcbase.js"></script>
<script src="${pageContext.request.contextPath}/js/sysUser.js"></script>
<script>

    $(function(){
        //点击已离职
        $('#leave_office_button').on('click',function(){
            // get_staff_list(1);
        })
        //第一次进入页面请求全部员工列表
        //get_staff_list(0);

    });

    // if (baseFn.notNull($.session.get('sysuser/list'))){

    // }

    //查询员工列表 userStatus：员工状态,0未离职，1已离职
    function get_staff_list(userStatus) {

        var store = document.getElementById('store');
        var value = store.options[store.options.selectedIndex].value;

        var data = {"userStatus":userStatus};

        if (value > -1){
            data["subclinicId"] = value;
        }

        // $.session.set('sysuser/list',JSON.stringify(data));

        $.ajax({
            url:baseUrl.base+baseUrl.sysuser+"list",
            type:"get",
            data:data,
            success:function(data) {
                var list = data.results.list;

                var tbody = '<tbody id = "staff_list_table_body">';
                for (var i = 0;i < list.length;i ++){
                    var staff = list[i];
                    tbody = tbody +
                        '<tr>\
                            <td class="storeSetting_table_width">\
                                <img class="bespeak_change_img" src="'+staff.userImg+'">\
                                <div class="card_name">\
                                    <span>' + staff.userNo + '</span>\
                                    <span>' + staff.userName + '</span>\
                                </div>\
                        </td>\
                            <td class="bespeak_change_two">\
                                <span>'+staff.subclinicName +'</span>\
                            </td>\
                            <td class="bespeak_change_people">\
                                <span>'+staff.roleName+'</span>\
                            </td>\
                            <td class="bespeak_change_time">'+staff.userPhone +'</td>\
                            <td class="storeSetting_table_width">'+staff.createTimeStr + '</td>\
                            <td class="bespeak_change_equic" style="text-align: center">\
                        <!--<button class="button_stsue_cancle">删除</button>-->\
                                <button userId='+ staff.userId +' class="button_stsue_change" onclick="to_content(this)">详情</button>\
                                <button userId='+ staff.userId +' class="button_stsue_accept" onclick="to_edit(this)">编辑</button>\
                            </td>\
                        </tr>';
                }
                tbody = tbody + '</tbody>';

                $('#staff_list_table_body').replaceWith(tbody);
            }
        })
    }

    //跳转详情页面
    function to_content(btn) {
        var userId = $(btn).attr("userId")
        window.location.href="${pageContext.request.contextPath}/sysuser/gotoCtaffManagementInfo?userId="+userId;
    }
    //跳转编辑
    function to_edit(btn) {
        var userId = $(btn).attr("userId")
        window.location.href="${pageContext.request.contextPath}/sysuser/gotoAddSysUser?userId="+userId;
    }

</script>
</html>